package action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

/**
 * 验证码是否正确
 * true:正确
 * false:错误
 * @author Administrator
 *
 */
@SuppressWarnings("serial")
public class ValidateCheckCodeServlet extends HttpServlet{
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String verifyCode = request.getParameter("verifyCode");//页面填写的验证码
		String checkcode = (String) request.getSession().getAttribute("checkcode");//程序生成的验证码
		boolean result = false;
		if (verifyCode.equalsIgnoreCase(checkcode)) {
			result = true;
		}
		PrintWriter out = response.getWriter();
		out.write(JSON.toJSONString(result));
	}
}
